const { defineConfig } = require('@vue/cli-service')
const config_build = require('./public/config_build')

const path = require('path')
function resolve(dir) {
  return path.join(__dirname, dir)
}

module.exports = defineConfig({
  transpileDependencies: true,
  lintOnSave: false,
  publicPath: config_build.ROUTE_PREFIX,
  outputDir: config_build.OUTPUT_DIR,
  devServer: {
    port: 8522,
    proxy: {
      "/hkfrich-api": {
        target: 'http://localhost:8521', //目标接口域名
        secure: false,            //false为http访问，true为https访问
        changeOrigin: true,      //是否跨域
        //重写路径  
        pathRewrite: {
          '^/hkfrich-api': ''
        },
      },
    }
  },
  //加载icon
  chainWebpack(config) {
    config.plugins.delete('preload') // TODO: need test
    config.plugins.delete('prefetch') // TODO: need test
    // set svg-sprite-loader
    config.module
      .rule('svg')
      .exclude.add(resolve('src/assets/icons'))
      .end()
    config.module
      .rule('icons')
      .test(/\.svg$/)
      .include.add(resolve('src/assets/icons'))
      .end()
      .use('svg-sprite-loader')
      .loader('svg-sprite-loader')
      .options({
        symbolId: 'icon-[name]'
      })
      .end()

  }

})
